libname gmath 'c:/My Documents/data/math/';

data IAT1; informat Item $12.;infile 'c:/My Documents/data/math/math.1.1996/outa.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Month   Day     Year    Hour    Min     Block   Trial   Icat
        Iscat   Inum  Item $  Lat     Error;
data IAT2; informat Item $12.;infile 'c:/My Documents/data/math/math.1.1996/outa1.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Month   Day     Year    Hour    Min     Block  Trial   Icat
        Iscat   Inum    Item $  Lat     Error;
data IAT3; informat Item $12.;infile 'c:/My Documents/data/math/math.1.1996/outa2.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Month   Day     Year    Hour    Min     Block  Trial   Icat
        Iscat   Inum  Item $  Lat     Error;
data IAT4; informat Item $12.;infile 'c:/My Documents/data/math/math.1.1996/outa3.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Month   Day     Year    Hour    Min     Block   Trial   Icat
        Iscat   Inum  Item $  Lat     Error;
data IAT5; informat Item $12.; infile 'c:/My Documents/data/math/math.1.1996/outa4.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Month   Day     Year    Hour    Min     Block  Trial   Icat
        Iscat   Inum    Item $  Lat     Error;
data IAT6; informat Item $12.;infile 'c:/My Documents/data/math/math.1.1996/outb.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Month   Day     Year    Hour    Min     Block  Trial   Icat
        Iscat   Inum  Item $  Lat     Error;
data IAT8;informat Item $12.; infile 'c:/My Documents/data/math/math.1.1996/outb2.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Month   Day     Year    Hour    Min     Block  Trial   Icat
        Iscat   Inum    Item $  Lat     Error;
data IAT9; informat Item $12.; infile 'c:/My Documents/data/math/math.1.1996/outb3.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Month   Day     Year    Hour    Min     Block  Trial   Icat
        Iscat   Inum  Item $  Lat     Error;
data IAT10;informat Item $12.; infile 'c:/My Documents/data/math/math.1.1996/outb4.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Month   Day     Year    Hour    Min     Block   Trial   Icat
        Iscat   Inum  Item $  Lat     Error;
data IAT11; informat Item $12.; infile 'c:/My Documents/data/math/math.1.1996/outb5.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Month   Day     Year    Hour    Min     Block  Trial   Icat
        Iscat   Inum    Item $  Lat     Error;
data IAT12; informat Item $12.;infile 'c:/My Documents/data/math/math.1.1996/outc.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Month   Day     Year    Hour    Min     Block  Trial   Icat
        Iscat   Inum  Item $  Lat     Error;
data IAT14;informat Item $12.;infile 'c:/My Documents/data/math/math.1.1996/outc2.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Month   Day     Year    Hour    Min     Block  Trial   Icat
        Iscat   Inum  Item $  Lat     Error;
data IAT15; informat Item $12.;infile 'c:/My Documents/data/math/math.1.1996/outc3.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Month   Day     Year    Hour    Min     Block  Trial   Icat
        Iscat   Inum  Item $  Lat     Error;
data IAT16; informat Item $12.; infile 'c:/My Documents/data/math/math.1.1996/oa1.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Month   Day     Year    Hour    Min     Block  Trial   Icat
        Iscat   Inum  Item $  Lat     Error;
data IAT17; informat Item $12.; infile 'c:/My Documents/data/math/math.1.1996/ob1.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Month   Day     Year    Hour    Min     Block  Trial   Icat
        Iscat   Inum  Item $  Lat     Error;
data IAT18; informat Item $12.; infile 'c:/My Documents/data/math/math.1.1996/oc1.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Month   Day     Year    Hour    Min     Block  Trial   Icat
        Iscat   Inum  Item $  Lat     Error;
data IAT19; informat Item $12.;infile 'c:/My Documents/data/math/math.1.1996/oc2.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Month   Day     Year    Hour    Min     Block  Trial   Icat
        Iscat   Inum  Item $  Lat     Error;
data IAT20; informat Item $12.; infile 'c:/My Documents/data/math/math.1.1996/omatha.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Month   Day     Year    Hour    Min     Block  Trial   Icat
        Iscat   Inum  Item $  Lat     Error;
data IAT21; informat Item $12.; infile 'c:/My Documents/data/math/math.1.1996/omathc.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Month   Day     Year    Hour    Min     Block  Trial   Icat
        Iscat   Inum  Item $  Lat     Error;
data IAT22; informat Item $12.; infile 'c:/My Documents/data/math/math.1.1996/omathb.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Month   Day     Year    Hour    Min     Block  Trial   Icat
        Iscat   Inum  Item $  Lat     Error;
data IAT23; informat Item $12.; infile 'c:/My Documents/data/math/math.2.1997/Adata6.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Block   Trial   Icat
        Iscat   Inum  Item $  Lat     Error resp $;
data IAT24; informat Item $12.; infile 'c:/My Documents/data/math/math.2.1997/B1data.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Block  Trial   Icat
        Iscat   Inum    Item $  Lat     Error resp $;
data IAT25;informat Item $12.; infile 'c:/My Documents/data/math/math.2.1997/Bdata6.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $      Block  Trial   Icat
        Iscat   Inum  Item $  Lat     Error resp $;
data IAT26; informat Item $12.; infile 'c:/My Documents/data/math/math.2.1997/Cdata.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Block   Trial   Icat
        Iscat   Inum  Item $  Lat     Error resp $;
data IAT27; informat Item $12.; infile 'c:/My Documents/data/math/math.2.1997/Cdata6.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Block   Trial   Icat
        Iscat   Inum  Item $  Lat     Error resp $;
data IAT28; informat Item $12.; infile 'c:/My Documents/data/math/math.2.1997/Bdata.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Block   Trial   Icat
        Iscat   Inum  Item $  Lat     Error resp $;
data IAT29; informat Item $12.; infile 'c:/My Documents/data/math/math.2.1997/Adata.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Block   Trial   Icat
        Iscat   Inum  Item $  Lat     Error resp $;
data IAT30; informat Item $12.; infile 'c:/My Documents/data/math/math.2.1997/Adatam4.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Block   Trial   Icat
        Iscat   Inum  Item $  Lat     Error resp $;
data IAT31; informat Item $12.; infile 'c:/My Documents/data/math/math.2.1997/Bdatam4.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Block   Trial   Icat
        Iscat   Inum  Item $  Lat     Error resp $;
data IAT32; informat Item $12.; infile 'c:/My Documents/data/math/math.2.1997/Cdatam4.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Block   Trial   Icat
        Iscat   Inum  Item $  Lat     Error resp $;
data IAT33; informat Item $12.; infile 'c:/My Documents/data/math/math.2.1997/Edatam4.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Block   Trial   Icat
        Iscat   Inum  Item $  Lat     Error resp $;
data IAT34; informat Item $12.; infile 'c:/My Documents/data/math/math.2.1997/Fdatam4.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay nPrac   nReal
        Sub     Sex $ Block   Trial   Icat
        Iscat   Inum  Item $  Lat     Error resp $;
data IAT35; informat Item $12.; infile 'c:/My Documents/data/math/math.3.1997/Adata6.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Block   Trial   Icat
        Iscat   Inum  Item $  Lat     Error resp $;
data IAT36; informat Item $12.; infile 'c:/My Documents/data/math/math.3.1997/B1data.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Block  Trial   Icat
        Iscat   Inum    Item $  Lat     Error resp $;
data IAT37; informat Item $12.; infile 'c:/My Documents/data/math/math.3.1997/Bdata6.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $      Block  Trial   Icat
        Iscat   Inum  Item $  Lat     Error resp $;
data IAT38; informat Item $12.; infile 'c:/My Documents/data/math/math.3.1997/Cdata6.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Block   Trial   Icat
        Iscat   Inum  Item $  Lat     Error resp $;
data IAT39; informat Item $12.; infile 'c:/My Documents/data/math/math.3.1997/E1data.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Block   Trial   Icat
        Iscat   Inum  Item $  Lat     Error resp $;
data IAT40; informat Item $12.; infile 'c:/My Documents/data/math/math.3.1997/Adata.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Block   Trial   Icat
        Iscat   Inum  Item $  Lat     Error;
data IAT41; informat Item $12.; infile 'c:/My Documents/data/math/math.3.1997/Bdata.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Block   Trial   Icat
        Iscat   Inum  Item $  Lat     Error resp $;
data IAT42; informat Item $12.; infile 'c:/My Documents/data/math/math.3.1997/AdataB.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Block   Trial   Icat
        Iscat   Inum  Item $  Lat     Error resp $;
data IAT43; informat Item $12.; infile 'c:/My Documents/data/math/math.3.1997/Cdata62.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Block   Trial   Icat
        Iscat   Inum  Item $  Lat     Error resp $;
data IAT44; informat Item $12.; infile 'c:/My Documents/data/math/math.3.1997/Fdata.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Block   Trial   Icat
        Iscat   Inum  Item $  Lat     Error resp $;
data IAT45; informat Item $12.; infile 'c:/My Documents/data/math/math.3.1997/Bdata6A.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Block   Trial   Icat
        Iscat   Inum  Item $  Lat     Error resp $;
data IAT46; informat Item $12.; infile 'c:/My Documents/data/math/math.3.1997/Adatac.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Block   Trial   Icat
        Iscat   Inum  Item $  Lat     Error resp $;
data IAT47; informat Item $12.; infile 'c:/My Documents/data/math/math.3.1997/Bdatab.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Block   Trial   Icat
        Iscat   Inum  Item $  Lat     Error resp $;
data IAT48; informat Item $12.; infile 'c:/My Documents/data/math/math.3.1997/Cdatab.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Block   Trial   Icat
        Iscat   Inum  Item $  Lat     Error resp $;
data IAT49; informat Item $12.; infile 'c:/My Documents/data/math/math.3.1997/Edatab.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Block   Trial   Icat
        Iscat   Inum  Item $  Lat     Error resp $;
data IAT50; informat Item $12.; infile 'c:/My Documents/data/math/math.3.1997/Fdatab.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Block   Trial   Icat
        Iscat   Inum  Item $  Lat     Error;
data IAT51; informat Item $12.; infile 'c:/My Documents/data/math/math.3.1997/Gdata.dat' delimiter='09'x;
  input InpFl $ Sess  Cat1 $  Cat2 $  Cat1p   Cat2p   Catsw   Delay  nPrac   nReal
        Sub     Sex $ Block   Trial   Icat
        Iscat   Inum  Item $  Lat     Error resp $;
data IAT;
   set IAT1 IAT2 IAT3 IAT4 IAT5 IAT6 IAT8 IAT9 IAT10 IAT11 IAT12
    IAT14 IAT15 IAT16 IAT17 IAT18 IAT19 IAT20 IAT21 IAT22
    IAT23 IAT24 IAT25 IAT26 IAT27 IAT28 IAT29 IAT30 IAT31 IAT32 IAT33
    IAT34 IAT35 IAT36 IAT37 IAT38 IAT39 IAT40 IAT41 IAT42 
    IAT43 IAT44 IAT45 IAT46 IAT47 IAT48 IAT49 IAT50 IAT51;

if cat1 = 'masfem' and cat2 = 'methey' then sub = sub + 1000;
if cat1 = 'matharts' and sub < 400 then sub = sub + 1000;

data IAT; set IAT;
/*study 1 bad subjects*/  if sub in (26, 46, 233) then delete;
/*Study 4 bad subjects*/  if sub in (707,722,548,503) then delete;
/*Study 5 bad subjects*/  if sub in (1121,1138,1226,1236,1242,1201) then delete;
if sub = 1118 then sex = 'f';

if cat1 = 'matharts' then task = 'mthArtAt';
if cat1 = 'matharts' and cat2 = 'masfem' then task = 'mstrotyp';
if cat1 = 'matharts' and cat2 = 'methey' then task = 'selfcon';
if cat1 = 'matharts' and cat2 = 'ithey' then task = 'selfcon';
if cat1 = 'masfem' and cat2 = 'methey' then task = 'genID';
if cat1 = 'lanmath1' then task = 'lngMthAt';
if cat1 = 'placnum1' then task = 'plcEquAt';
if cat1 = 'numlet1' then task = 'numLetAt';
if cat1 = 'sciarts' then task = 'sciArtAt';

If Lat > 3000 then lat = 3000;If Lat < 300 then lat = 300;/*If Error > 0 then delete;*/
if sex = 'n' then delete;if trial in (1,2) then delete;

if sub < 1000 then do;
  if block in (3,6,10,13,17,20,24,27) then delete;  /*all practice combined*/
  if block in (2,9,16,23) then gngroup = 'ApuSngl';
  if block in (1,5,8,12,15,19,22,26) then gngroup = 'BmlSngl';

  if Cat1p = 1 and Cat2p = 0 and block = 4 then hndgroup = 1;if Cat1p = 1 and Cat2p = 0 and block = 11 then hndgroup = 1;
  if Cat1p = 1 and Cat2p = 0 and block = 18 then hndgroup = 1;if Cat1p = 1 and Cat2p = 0 and block = 25 then hndgroup = 1;
  if Cat1p = 0 and Cat2p = 1 and block = 4 then hndgroup = 2;if Cat1p = 0 and Cat2p = 1 and block = 11 then hndgroup = 2;
  if Cat1p = 0 and Cat2p = 1 and block = 18 then hndgroup = 2;if Cat1p = 0 and Cat2p = 1 and block = 25 then hndgroup = 2;
  if Cat1p = 1 and Cat2p = 1 and block = 7 then hndgroup = 2;if Cat1p = 1 and Cat2p = 1 and block = 14 then hndgroup = 2;
  if Cat1p = 1 and Cat2p = 1 and block = 21 then hndgroup = 2;if Cat1p = 1 and Cat2p = 1 and block = 28 then hndgroup = 2;
  if Cat1p = 0 and Cat2p = 0 and block = 7 then hndgroup = 1;if Cat1p = 0 and Cat2p = 0 and block = 14 then hndgroup = 1;
  if Cat1p = 0 and Cat2p = 0 and block = 21 then hndgroup = 1;if Cat1p = 0 and Cat2p = 0 and block = 28 then hndgroup = 1;
  if Cat1p = 1 and Cat2p = 1 and block = 4 then hndgroup = 3;if Cat1p = 1 and Cat2p = 1 and block = 11 then hndgroup = 3;
  if Cat1p = 1 and Cat2p = 1 and block = 18 then hndgroup = 3;if Cat1p = 1 and Cat2p = 1 and block = 25 then hndgroup = 3;
  if Cat1p = 0 and Cat2p = 0 and block = 4 then hndgroup = 4;if Cat1p = 0 and Cat2p = 0 and block = 11 then hndgroup = 4;
  if Cat1p = 0 and Cat2p = 0 and block = 18 then hndgroup = 4;if Cat1p = 0 and Cat2p = 0 and block = 25 then hndgroup = 4;
  if Cat1p = 1 and Cat2p = 0 and block = 7 then hndgroup = 4;if Cat1p = 1 and Cat2p = 0 and block = 14 then hndgroup = 4;
  if Cat1p = 1 and Cat2p = 0 and block = 21 then hndgroup = 4;if Cat1p = 1 and Cat2p = 0 and block = 28 then hndgroup = 4;
  if Cat1p = 0 and Cat2p = 1 and block = 7 then hndgroup = 3;if Cat1p = 0 and Cat2p = 1 and block = 14 then hndgroup = 3;
  if Cat1p = 0 and Cat2p = 1 and block = 21 then hndgroup = 3;if Cat1p = 0 and Cat2p = 1 and block = 28 then hndgroup = 3;
  If Cat1p = 1 and Cat2p = 0 and block = 25 then hndgroup = 1;If Cat1p = 0 and Cat2p = 1 and block = 25 then hndgroup = 2;
  If Cat1p = 1 and Cat2p = 1 and block = 28 then hndgroup = 2;If Cat1p = 0 and Cat2p = 0 and block = 28 then hndgroup = 1;
  If Cat1p = 1 and Cat2p = 1 and block = 25 then hndgroup = 3;If Cat1p = 0 and Cat2p = 0 and block = 25 then hndgroup = 4;
  If Cat1p = 1 and Cat2p = 0 and block = 28 then hndgroup = 4;If Cat1p = 0 and Cat2p = 1 and block = 28 then hndgroup = 3;
end;

If sub > 1000 then do;
  If block in (3,6,9) then delete;
  if block in (1) then gngroup = 'ApuSngl';if block in (2,5,8) then gngroup = 'BmlSngl';
  hndgroup = 0;
  if Cat1p = 1 and Cat2p = 0 and block = 4 then hndgroup = 1;if Cat1p = 0 and Cat2p = 0 and block = 4 then hndgroup = 4;
  if Cat1p = 0 and Cat2p = 0 and block = 7 then hndgroup = 1;if Cat1p = 1 and Cat2p = 0 and block = 7 then hndgroup = 4;
  if Cat1p = 1 and Cat2p = 0 and block = 10 then hndgroup = 1;if Cat1p = 0 and Cat2p = 0 and block = 10 then hndgroup = 4;
  if Cat1p = 1 and Cat2p = 0 and block = 11 then hndgroup = 1;if Cat1p = 0 and Cat2p = 0 and block = 11 then hndgroup = 4;
  if Cat1p = 0 and Cat2p = 0 and block = 13 then hndgroup = 1;if Cat1p = 1 and Cat2p = 0 and block = 13 then hndgroup = 4;
  if Cat1p = 0 and Cat2p = 0 and block = 14 then hndgroup = 1;if Cat1p = 1 and Cat2p = 0 and block = 14 then hndgroup = 4;
  if Cat1p = 1 and Cat2p = 0 and block = 16 then hndgroup = 1;if Cat1p = 0 and Cat2p = 0 and block = 16 then hndgroup = 4;
  if Cat1p = 1 and Cat2p = 0 and block = 17 then hndgroup = 1;if Cat1p = 0 and Cat2p = 0 and block = 17 then hndgroup = 4;
  if Cat1p = 1 and Cat2p = 0 and block = 18 then hndgroup = 1;if Cat1p = 0 and Cat2p = 0 and block = 18 then hndgroup = 4;
  if Cat1p = 0 and Cat2p = 0 and block = 19 then hndgroup = 1;if Cat1p = 1 and Cat2p = 0 and block = 19 then hndgroup = 4;
  if Cat1p = 0 and Cat2p = 0 and block = 20 then hndgroup = 1;if Cat1p = 1 and Cat2p = 0 and block = 20 then hndgroup = 4;
  if Cat1p = 0 and Cat2p = 0 and block = 21 then hndgroup = 1;if Cat1p = 1 and Cat2p = 0 and block = 21 then hndgroup = 4;
  if Cat1p = 1 and Cat2p = 0 and block = 23 then hndgroup = 1;if Cat1p = 0 and Cat2p = 0 and block = 23 then hndgroup = 4;
  if Cat1p = 1 and Cat2p = 0 and block = 24 then hndgroup = 1;if Cat1p = 0 and Cat2p = 0 and block = 24 then hndgroup = 4;
  if Cat1p = 0 and Cat2p = 0 and block = 26 then hndgroup = 1;if Cat1p = 1 and Cat2p = 0 and block = 26 then hndgroup = 4;
  if Cat1p = 0 and Cat2p = 0 and block = 27 then hndgroup = 1;if Cat1p = 1 and Cat2p = 0 and block = 27 then hndgroup = 4;

   if InpFl = 'mfpi1' or InpFl = 'MFPI1' then do;
      order = 'firstord'; if block in (10,13,17,20,23,26) then delete;
      if block in (12,16,19,22,25) then gngroup = 'BmlSngl'; if block in (15) then gngroup = 'ApuSngl';  end;
   if InpFl = 'mfpi2' or InpFl = 'MFPI2' then do;
      order = 'secndord'; if block in (10,13,17,20,23,26) then delete;
      if block in (12,16,19,22,25) then gngroup = 'BmlSngl'; if block in (15) then gngroup = 'ApuSngl';  end;
   if InpFl = 'fpim1' or InpFl = 'FPIM1' then do;
      order = 'firstord'; if block in (10,13,16,19,22,25) then delete;
      if block in (12,15,18,21,24) then gngroup = 'BmlSngl';  end;
   if InpFl = 'fpim2' or InpFl = 'FPIM2' then do;
      order = 'secndord'; if block in (10,13,16,19,22,25) then delete;
      if block in (12,15,18,21,24) then gngroup = 'BmlSngl'; end;
   if InpFl = 'pimf1' or InpFl = 'PIMF1' then do;
      order = 'firstord'; if block in (12,15,18,22,25) then delete;
      if block in (11,14,17,21,24) then gngroup = 'BmlSngl'; if block in (20) then gngroup = 'ApuSngl';  end;
   if InpFl = 'pimf2' or InpFl = 'PIMF2' then do;
      order = 'secndord'; if block in (12,15,18,22,25) then delete;
      if block in (11,14,17,21,24) then gngroup = 'BmlSngl'; if block in (20) then gngroup = 'ApuSngl';  end;
   if InpFl = 'imfp1' or InpFl = 'IMFP1' then do;
      order = 'firstord'; if block in (12,16,19,23,26) then delete;
      if block in (11,15,18,22,25) then gngroup = 'BmlSngl'; if block in (14,21) then gngroup = 'ApuSngl';  end;
   if InpFl = 'imfp2' or InpFl = 'IMFP2' then do;
      order = 'secndord'; if block in (12,16,19,23,26) then delete;
      if block in (11,15,18,22,25) then gngroup = 'BmlSngl'; if block in (14,21) then gngroup = 'ApuSngl';  end;
end;

if gngroup in ('ApuSngl', 'BmlSngl') then gngroup = 'ASingle';
else if hndgroup in (1,2) then gngroup = 'posmath';
else if hndgroup in (3,4) then gngroup = 'negmath';
speed = 1000/lat;

if Icat = 0 and Iscat = 0 and gngroup = 'posmath' then sptrgrp = 'langunp';
if Icat = 0 and Iscat = 1 and gngroup = 'posmath' then sptrgrp = 'mathple';
if Icat = 1 and Iscat = 0 and gngroup = 'posmath' then sptrgrp = 'plemath';
if Icat = 1 and Iscat = 1 and gngroup = 'posmath' then sptrgrp = 'unplang';
if Icat = 0 and Iscat = 0 and gngroup = 'negmath' then sptrgrp = 'langple';
if Icat = 0 and Iscat = 1 and gngroup = 'negmath' then sptrgrp = 'mathunp';
if Icat = 1 and Iscat = 0 and gngroup = 'negmath' then sptrgrp = 'plelang';
if Icat = 1 and Iscat = 1 and gngroup = 'negmath' then sptrgrp = 'unpmath';
if Icat = 0 and Iscat = 0 and gngroup = 'posmath' then crtrgrp = 'lanunp';
if Icat = 0 and Iscat = 1 and gngroup = 'posmath' then crtrgrp = 'matple';
if Icat = 1 and Iscat = 0 and gngroup = 'posmath' then crtrgrp = 'matple';
if Icat = 1 and Iscat = 1 and gngroup = 'posmath' then crtrgrp = 'lanunp';
if Icat = 0 and Iscat = 0 and gngroup = 'negmath' then crtrgrp = 'lanple';
if Icat = 0 and Iscat = 1 and gngroup = 'negmath' then crtrgrp = 'matunp';
if Icat = 1 and Iscat = 0 and gngroup = 'negmath' then crtrgrp = 'lanple';
if Icat = 1 and Iscat = 1 and gngroup = 'negmath' then crtrgrp = 'matunp';

proc sort; by sub task gngroup sex order;run;
proc means noprint;
  by sub task gngroup sex order; var speed; output out=means  mean=speed;run;
proc transpose data=means prefix=speed name=name out=spdmeans;
  by sub sex order;run;
proc sort; by name;run;
data prac; set spdmeans; if name ^= 'speed' then delete;
proc sort data=prac; by sub;run;


/* Bringing explicit data into analysis */
data exp1;informat major $40.;informat ethspec $15.;
  infile 'c:/My Documents/data/math/math.1.1996/paper.dat' delimiter='09'x;
  input sub orderme Mathtemp Mgoodbad Mhapysad Mdeldsgt Mbeaugly Mappravd Munafaf
    Mfmlmale EnglTemp Egoodbad Ehapysad Edeldsgt Ebeaugly Eappravd Eunafaf Efmlmale
    likemath likeread likesci likeengl APmath APsci highmath biology physio chem
    physics psych compsci engineer major $ majorcat age year gender $ SATmath SATverb
    ethncty ethspec $ bornUS UShwlng Engfirst Enghwlng biosocal;
data exp2;informat major $40.; informat ethspec $15.;
  infile 'c:/My Documents/data/math/math.2.1997/explicit.txt' delimiter='09'x;
  input sub orderme Mathtemp Mgoodbad Mhapysad Mdeldsgt Mbeaugly Mappravd Munafaf
    Mfmlmale EnglTemp Egoodbad Ehapysad Edeldsgt Ebeaugly Eappravd Eunafaf Efmlmale
    mathper artsper martcomp usemath major $ majorcat age year gender $
    ethncty ethspec $ bornUS UShwlng Engfirst Enghwlng SATmath SATverb;
data exp3;informat major $40.;informat ethspec $15.;
  infile 'c:/My Documents/data/math/math.3.1997/M5explicit.txt' delimiter='09'x;
  input sub orderme Mathtemp Mgoodbad Mhapysad Mdeldsgt Mbeaugly Mappravd Munafaf
    Mfmlmale EnglTemp Egoodbad Ehapysad Edeldsgt Ebeaugly Eappravd Eunafaf Efmlmale
    mathper artsper martcomp usemath major $ majorcat age year gender $
    ethncty ethspec $ bornUS UShwlng Engfirst Enghwlng SATmath SATverb;
   sub = sub + 1000;
data explicit; set exp1 exp2 exp3;

proc sort data=explicit; by sub;run;
data comb;merge prac (in=frog) explicit; by sub; if frog;run;
proc sort; by sex sub;run;
data comb;set comb;
  if sub < 300 then LMpmath = speed3;
  if sub < 300 then LMnmath = speed2;
  if sub < 300 then LMsingl = speed1;
  if sub < 300 then NLpmath = speed6;
  if sub < 300 then NLnmath = speed5;
  if sub < 300 then NLsingl = speed4;
  if sub < 300 then PEpmath = speed9;
  if sub < 300 then PEnmath = speed8;
  if sub < 300 then PEsingl = speed7;
  if sub > 300 and sub < 1000 then LMpmath = speed3;
  if sub > 300 and sub < 1000 then LMnmath = speed2;
  if sub > 300 and sub < 1000 then LMsingl = speed1;
  if sub > 300 and sub < 1000 then MApmath = speed5;
  if sub > 300 and sub < 1000 then MAnmath = speed6;
  if sub > 300 and sub < 1000 then MAsingl = speed4;
  if sub > 300 and sub < 1000 then SApmath = speed8;
  if sub > 300 and sub < 1000 then SAnmath = speed9;
  if sub > 300 and sub < 1000 then SAsingl = speed7;
  if sub > 300 and sub < 1000 then Mathself = speed11;
  if sub > 300 and sub < 1000 then Artsself = speed12;
  if sub > 300 and sub < 1000 then IDsingl = speed10;
  if sub > 1000 then GIDmale = speed2;
  if sub > 1000 then GIDfem = speed3;
  if sub > 1000 then GIDsngl = speed1;
  if sub > 1000 then Mathmasc = speed5;
  if sub > 1000 then Mathfem  = speed6;
  if sub > 1000 then Strosngl  = speed4;
  if sub > 1000 then MApmath = speed8;
  if sub > 1000 then MAnmath = speed9;
  if sub > 1000 then MAsngl = speed7;
  if sub > 1000 then Mathself = speed11;
  if sub > 1000 then Artsself = speed12;
  if sub > 1000 then IDsngl = speed10;
  IM = Mathself - Artsself;
  LM = LMpmath - LMnmath; MA = MApmath - MAnmath;
  SA = SApmath - SAnmath; GID = GIDmale - GIDfem;
  MStro = Mathmasc - Mathfem; NL = NLpmath - NLnmath;
  PE = PEpmath - PEnmath;
  if sub > 300 then do;
     Mgoodbad = - Mgoodbad;Mdeldsgt = - Mdeldsgt; Munafaf = - Munafaf;
     Egoodbad = - Egoodbad;Edeldsgt = - Edeldsgt; Eunafaf = - Eunafaf;
  end;
  Mposavg = mean (Mhapysad, Mgoodbad, Mdeldsgt, Mbeaugly, Mappravd, Munafaf);
  Eposavg = mean (Ehapysad, Egoodbad, Edeldsgt, Ebeaugly, Eappravd, Eunafaf);
  SATperf = SATmath - SATverb; EXPpref = Mposavg - Eposavg;
  temp = mathtemp - engltemp;
  if sex = 'm' then gen = 0; if sex = 'f' then gen = 1;
  citizen = 'foreign';
  if UShwlng > 4 then citizen='US'; if UShwlng < .1 then citizen='US';
  if majorcat = 3 then maj = 2; if majorcat = 4 then maj = 3;
  if majorcat < 3 then maj = 1;
  if maj = 1 then mgroup = 'science'; if maj = 2 then mgroup = 'nonsci';
  if maj = 3 then mgroup = 'nonsci';
  expsl = artsper - mathper;
  if mgroup = 'science' and sex = 'f' then toughtst = 'mathfem';
  if mgroup = 'nonsci' and sex = 'm' then toughtst = 'artsmale';
  race = 'other';
  if ethncty = 3 then race = 'white'; if ethncty = 2 then race = 'asian';run;
data gmath.IAT; set comb;run;

